#ifndef VICONFRAME_H
#define VICONFRAME_H

#include "ViconBody.h"
#include <stdio.h>
#include <string.h>

class ViconBody;
class ViconFrame
{
private:
	friend class ViconHandler;

	void AddBody(ViconBody* _s);

	ViconBody* m_bodyList;

	long int m_frameNum;

	void SetFrameNum(long int _f) { m_frameNum = _f; }
	

public:
	inline ViconBody* GetBodyList() { return m_bodyList; }
	inline long int GetFrameNum() { return m_frameNum; }
	
	ViconFrame() : m_frameNum(0), m_bodyList(NULL) {}

	ViconBody* GetBodyByName(const char* _fullName)
	{ ViconBody *s = m_bodyList;
	while (s) {	if (!strcmp(_fullName, s->GetName()))return s;	s = s->GetNext();}return NULL;}

	ViconBody* GetBodyByName(const char* _skeleton, const char* _bone)
	{ char _fullName[MAX_BODYNAME_LEN]; sprintf_s(_fullName, MAX_BODYNAME_LEN, "%s:%s", _skeleton, _bone);
	ViconBody *s = m_bodyList;
	while (s) {	if (!strcmp(_fullName, s->GetName()))return s;	s = s->GetNext();}return NULL;}

	
	~ViconFrame()
	{ while (m_bodyList) { ViconBody *s = m_bodyList; if (s) { m_bodyList = m_bodyList->GetNext(); delete s; } } }

};

#endif
